import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { User } from '../../users/entities/user.entity';

@Entity()
export class Comment {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'int', comment: '评论的文章id 为0为留言板评论', default: 0 })
  articleId: number;

  @Column({ type: 'int', comment: '父级评论的ID 根评论为0' })
  parent: number;

  // 一级评论 root=parent=0 二级评论 parent=root!=0 三级评论 parent!=root
  @Column({ type: 'int', comment: '根评论的ID 根评论为0' })
  root: number;

  @Column({ type: 'int', comment: '点赞数' })
  like: number = 0;

  @Column({ type: 'text', comment: '评论内容' })
  content: string;

  // 审核中1 审核未通过2 审核通过3
  @Column({ type: 'tinyint', comment: '审核中1 审核未通过2 审核通过3' })
  status: number;

  @ManyToOne(() => User, (user) => user.comments)
  member: User;

  @CreateDateColumn()
  createTime: Date;
}
